package com.qingzhu.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class CreateSqlSessionFactory {
    private static String file;
    private static SqlSessionFactory factory;

    static {
        file = "config/qingzhu-config.xml";
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        factory = new SqlSessionFactoryBuilder().build(inputStream);
    }

    public static SqlSessionFactory getFactory() {
        return factory;
    }
}
